package com.dyh.quickdemo.trace;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/*
@Author=Joey Wheeler
@Date=2021/3/9 14:38
*/
public abstract class AbstractNode implements Node{

    protected String title;
    protected String detail;
    protected List<Clue> clues = new ArrayList<>();


    @Override
    public String getTitle() {
        return title;
    }

    @Override
    public void setTitle(String title) {
        this.title = title;
    }

    @Override
    public String getDetail() {
        return detail;
    }
    @Override
    public void setDetail(String detail) {
        this.detail = detail;
    }
    @Override
    public List<Clue> getClues() {
        return clues;
    }

    public void setClues(List<Clue> clues) {
        this.clues = clues;
    }

    public void setClues(Clue... clues) {
        this.clues = Arrays.asList(clues);
    }

    public void setClues(String... clueTitles) {
        this.clues = Arrays.stream(clueTitles).map(BaseClue::new)
        .collect(Collectors.toList());
    }

    public  Clue addClue(Clue clue){
        this.clues.add(clue);
        return clue;
    }

    public  Clue addClue(String clueTitle){
        Clue  clue = new BaseClue(clueTitle);
        this.clues.add(clue);
        return clue;
    }


}
